<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="adver"><img src="images/adv.jpg"/></div>
<div id="main">
    <img src="images/main1.jpg"/>
    <img src="images/main2.jpg"/>
    <img src="images/main3.jpg"/>
</div>
<script>
    var adverTop;
    var adverObj;
    function inix() {
        adverObj=document.getElementById("adver");
        if (adverObj.currentStyle){
            adverTop=parseInt(adverObj.currentStyle.top);
            adverLeft=parseInt(adverObj.currentStyle.left);

        }else {
            adverTop=parseInt(document.defaultView.getComputedStyle(adverObj,null).top);
            adverLeft=parseInt(document.defaultView.getComputedStyle(adverObj,null).left);
        }
    }
    function move() {
        var sTop=parseInt(document.documentElement.scrollTop||document.body.scrollTop);
        var sLeft=parseInt(document.documentElement.scrollLeft||document.body.scrollLeft);
        adverObj.style.top=adverTop+sTop+"px";
        adverObj.style.left=adverLeft+sLeft+"px";
    }
    window.onload=inix;
    window.onscroll=move;
</script>
</body>
</html>